using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using VOL.Entity.DomainModels;
using SqlSugar;

namespace VOL.demo.Repositories
{
    public partial class Sys_UserRepository
    {
        /// <summary>
        /// 获取用户下拉选项
        /// </summary>
        /// <returns>用户列表</returns>
        public async Task<List<Sys_User>> GetUserOptionsAsync()
        {
            return await DbContext.Queryable<Sys_User>()
                .Where(x => x.Enable == 1)
                .OrderBy(x => x.UserName)
                .ToListAsync();
        }

        /// <summary>
        /// 根据用户ID获取用户信息
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <returns>用户信息</returns>
        public async Task<Sys_User> GetUserByIdAsync(int userId)
        {
            return await DbContext.Queryable<Sys_User>()
                .Where(x => x.User_Id == userId && x.Enable == 1)
                .FirstAsync();
        }
    }
}
